/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package VIEW;

import BEANS.ComboItem;
import CONTROLLERS.TransferController;
import UTIL.InputValidator;
import java.awt.event.KeyEvent;
import javax.swing.JComboBox;
import javax.swing.JTable;

/**
 *
 * @author Belthazod
 */
public class TransferUI extends javax.swing.JPanel {
    TransferController transferController;
    /**
     * Creates new form Transfer
     */
    public TransferUI() {
        try{
        initComponents();
        transferController = new TransferController(productTableSearchInput, clear, 
                transferProductsTable, truckTable, filterCategoryComboBox, 
                productFilterSupplierComboBox, transferFromComboBox, transferToComboBox, 
                quantityInputDialog, inputQuantityTextField, editQuantity, 
                editQuantityDialog, transferDate, remarksTextArea, dateTo, dateFrom, historyTable);
        InputValidator.enabler(transferProductsTable, addToTruckButton);
        InputValidator.enabler(truckTable, removeItemButton);
        InputValidator.enabler(truckTable, editButton);
        transferController.justDClickIt(transferProductsTable);
        transferController.justDClickIt2(truckTable);
       //transferController.justDClickItToDelete(truckTable);
        quantityInputDialog.setLocationRelativeTo(null);
        editQuantityDialog.setLocationRelativeTo(null);
        transferHistoryDialog.setLocationRelativeTo(null);
        
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        transferDialog = new javax.swing.JDialog();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        quantityInputDialog = new javax.swing.JDialog();
        inputQuantityTextField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        quantityCancelButton = new javax.swing.JButton();
        quantityInputButton = new javax.swing.JButton();
        editQuantityDialog = new javax.swing.JDialog();
        editQuantityOK = new javax.swing.JButton();
        editQuantityCancel = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        editQuantity = new javax.swing.JTextField();
        transferHistoryDialog = new javax.swing.JDialog();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        historyTable = new javax.swing.JTable();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        dateFrom = new datechooser.beans.DateChooserCombo();
        dateTo = new datechooser.beans.DateChooserCombo();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        transferFromComboBox = new javax.swing.JComboBox<ComboItem>();
        jButton1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        truckTable = new javax.swing.JTable();
        addToTruckButton = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        transferProductsTable = new javax.swing.JTable();
        transferToComboBox = new javax.swing.JComboBox<ComboItem>();
        removeItemButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        clear = new javax.swing.JLabel();
        productFilterSupplierComboBox = new javax.swing.JComboBox<ComboItem>();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        filterCategoryComboBox = new javax.swing.JComboBox<ComboItem>();
        productTableSearchInput = new javax.swing.JTextField();
        clearTableButton = new javax.swing.JButton();
        editButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        remarksTextArea = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jButton2 = new javax.swing.JButton();
        transferDate = new datechooser.beans.DateChooserCombo();
        jLabel11 = new javax.swing.JLabel();

        transferDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        quantityInputDialog.setTitle("Input Quantity");
        quantityInputDialog.setBounds(new java.awt.Rectangle(0, 0, 250, 130));
        quantityInputDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        quantityInputDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                quantityInputDialogWindowClosed(evt);
            }
        });

        inputQuantityTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inputQuantityTextFieldActionPerformed(evt);
            }
        });
        inputQuantityTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                inputQuantityTextFieldKeyPressed(evt);
            }
        });

        jLabel9.setText("Enter quantity:");

        quantityCancelButton.setText("Cancel");
        quantityCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quantityCancelButtonActionPerformed(evt);
            }
        });

        quantityInputButton.setText("OK");
        quantityInputButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quantityInputButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout quantityInputDialogLayout = new javax.swing.GroupLayout(quantityInputDialog.getContentPane());
        quantityInputDialog.getContentPane().setLayout(quantityInputDialogLayout);
        quantityInputDialogLayout.setHorizontalGroup(
            quantityInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(quantityInputDialogLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel9)
                .addGap(26, 26, 26)
                .addComponent(inputQuantityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(53, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, quantityInputDialogLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(quantityInputButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(quantityCancelButton)
                .addGap(30, 30, 30))
        );
        quantityInputDialogLayout.setVerticalGroup(
            quantityInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(quantityInputDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(quantityInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(inputQuantityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(quantityInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(quantityInputButton)
                    .addComponent(quantityCancelButton))
                .addContainerGap())
        );

        editQuantityDialog.setTitle("Edit Quantity");
        editQuantityDialog.setBounds(new java.awt.Rectangle(0, 0, 250, 130));
        editQuantityDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                editQuantityDialogWindowClosed(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                editQuantityDialogWindowClosing(evt);
            }
        });

        editQuantityOK.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        editQuantityOK.setText("OK");
        editQuantityOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editQuantityOKActionPerformed(evt);
            }
        });

        editQuantityCancel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        editQuantityCancel.setText("Cancel");
        editQuantityCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editQuantityCancelActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel10.setText("Enter quantity:");

        editQuantity.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        editQuantity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editQuantityActionPerformed(evt);
            }
        });
        editQuantity.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                editQuantityKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout editQuantityDialogLayout = new javax.swing.GroupLayout(editQuantityDialog.getContentPane());
        editQuantityDialog.getContentPane().setLayout(editQuantityDialogLayout);
        editQuantityDialogLayout.setHorizontalGroup(
            editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editQuantityDialogLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(editQuantityDialogLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(18, 18, 18)
                        .addComponent(editQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, editQuantityDialogLayout.createSequentialGroup()
                        .addComponent(editQuantityOK, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(editQuantityCancel)))
                .addContainerGap(45, Short.MAX_VALUE))
        );
        editQuantityDialogLayout.setVerticalGroup(
            editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editQuantityDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(editQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(editQuantityDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(editQuantityOK)
                    .addComponent(editQuantityCancel))
                .addContainerGap())
        );

        transferHistoryDialog.setTitle("Transfer History");
        transferHistoryDialog.setBounds(new java.awt.Rectangle(0, 0, 900, 600));

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel12.setText("Transfer History");

        historyTable.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        historyTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Date", "Product Name", "Quantity", "Transferred From", "Transferred To", "Remarks"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        historyTable.setRowHeight(20);
        jScrollPane4.setViewportView(historyTable);

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel13.setText("From:");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel14.setText("To:");

        dateFrom.setWeekStyle(datechooser.view.WeekDaysStyle.FULL);
        dateFrom.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
            public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
                dateFromOnSelectionChange(evt);
            }
        });
        dateFrom.addCommitListener(new datechooser.events.CommitListener() {
            public void onCommit(datechooser.events.CommitEvent evt) {
                dateFromOnCommit(evt);
            }
        });

        dateTo.setWeekStyle(datechooser.view.WeekDaysStyle.FULL);
        dateTo.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
            public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
                dateToOnSelectionChange(evt);
            }
        });
        dateTo.addCommitListener(new datechooser.events.CommitListener() {
            public void onCommit(datechooser.events.CommitEvent evt) {
                dateToOnCommit(evt);
            }
        });

        javax.swing.GroupLayout transferHistoryDialogLayout = new javax.swing.GroupLayout(transferHistoryDialog.getContentPane());
        transferHistoryDialog.getContentPane().setLayout(transferHistoryDialogLayout);
        transferHistoryDialogLayout.setHorizontalGroup(
            transferHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(transferHistoryDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(transferHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 890, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, transferHistoryDialogLayout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateFrom, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateTo, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        transferHistoryDialogLayout.setVerticalGroup(
            transferHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(transferHistoryDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addGroup(transferHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(transferHistoryDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(dateFrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(dateTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 492, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        setBackground(new java.awt.Color(204, 204, 204));
        setPreferredSize(new java.awt.Dimension(814, 592));
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel1.setText("Transfer From:");
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 80, -1, -1));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel2.setText("Transfer To:");
        add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(820, 80, -1, -1));

        transferFromComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        transferFromComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Main Branch", "Pacdal Branch", "Marcos Highway Branch", "Trinidad Branch" }));
        transferFromComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transferFromComboBoxActionPerformed(evt);
            }
        });
        add(transferFromComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 100, 200, -1));

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton1.setText("Transfer");
        jButton1.setEnabled(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(940, 610, 124, -1));

        truckTable.setAutoCreateRowSorter(true);
        truckTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "product_id", "Product Name", "In-store", "Quantity"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        truckTable.setRowHeight(20);
        truckTable.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                truckTableKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                truckTableKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(truckTable);
        if (truckTable.getColumnModel().getColumnCount() > 0) {
            truckTable.getColumnModel().getColumn(0).setResizable(false);
            truckTable.getColumnModel().getColumn(2).setMaxWidth(70);
            truckTable.getColumnModel().getColumn(3).setMaxWidth(70);
        }
        truckTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

        add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 180, 490, 350));

        addToTruckButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        addToTruckButton.setText("Add To List");
        addToTruckButton.setEnabled(false);
        addToTruckButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addToTruckButtonActionPerformed(evt);
            }
        });
        add(addToTruckButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 610, 110, 27));

        transferProductsTable.setAutoCreateRowSorter(true);
        transferProductsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ProductID", "Product Name", "Category", "Quantity", "Re-order"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        transferProductsTable.setRowHeight(20);
        transferProductsTable.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                transferProductsTableKeyPressed(evt);
            }
        });
        jScrollPane2.setViewportView(transferProductsTable);
        transferProductsTable.getColumnModel().getColumn(0).setMaxWidth(0);
        transferProductsTable.getColumnModel().getColumn(0).setMinWidth(0);
        transferProductsTable.getColumnModel().getColumn(0).setPreferredWidth(0);
        if (transferProductsTable.getColumnModel().getColumnCount() > 0) {
            transferProductsTable.getColumnModel().getColumn(0).setResizable(false);
            transferProductsTable.getColumnModel().getColumn(0).setPreferredWidth(0);
            transferProductsTable.getColumnModel().getColumn(3).setMaxWidth(80);
            transferProductsTable.getColumnModel().getColumn(4).setMaxWidth(80);
        }

        add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 530, 420));

        transferToComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        transferToComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Marcos Highway Branch", "Trinidad Branch", "Pacdal Branch", "Main Branch" }));
        transferToComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transferToComboBoxActionPerformed(evt);
            }
        });
        add(transferToComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(820, 100, 200, -1));

        removeItemButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        removeItemButton.setText("Delete");
        removeItemButton.setEnabled(false);
        removeItemButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeItemButtonActionPerformed(evt);
            }
        });
        add(removeItemButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 140, 80, 30));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Product Transfer");
        add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(488, 0, -1, -1));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel5.setText("Products Available For Transfer");
        add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, -1, -1));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel6.setText("Products Selected");
        add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 150, -1, -1));

        jButton3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton3.setText("Search");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 150, -1, -1));

        clear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/UI ICONS/xmark.png"))); // NOI18N
        clear.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                clearMouseClicked(evt);
            }
        });
        add(clear, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 150, -1, 26));
        clear.setVisible(false);

        productFilterSupplierComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        productFilterSupplierComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        productFilterSupplierComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                productFilterSupplierComboBoxActionPerformed(evt);
            }
        });
        add(productFilterSupplierComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(84, 87, 210, -1));

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel8.setText("Supplier:");
        add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 86, -1, -1));

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel7.setText("Category:");
        add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 58, -1, -1));

        filterCategoryComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        filterCategoryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        filterCategoryComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filterCategoryComboBoxActionPerformed(evt);
            }
        });
        add(filterCategoryComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(83, 59, 210, -1));

        productTableSearchInput.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        productTableSearchInput.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                productTableSearchInputKeyPressed(evt);
            }
        });
        add(productTableSearchInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 150, 199, -1));

        clearTableButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        clearTableButton.setText("Clear All");
        clearTableButton.setEnabled(false);
        clearTableButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearTableButtonActionPerformed(evt);
            }
        });
        add(clearTableButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(981, 140, -1, 30));

        editButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        editButton.setText("Edit Quantity");
        editButton.setEnabled(false);
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButtonActionPerformed(evt);
            }
        });
        add(editButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(760, 140, 120, 30));

        remarksTextArea.setColumns(20);
        remarksTextArea.setRows(5);
        jScrollPane3.setViewportView(remarksTextArea);

        add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 550, 490, 50));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("Remarks");
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 530, -1, -1));

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 30, 10, 620));

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton2.setText("View Transfer History");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(900, 10, -1, -1));

        transferDate.setFormat(0);
        add(transferDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 50, 190, -1));

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel11.setText("Date:");
        add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 50, -1, -1));
    }// </editor-fold>//GEN-END:initComponents

    private void addToTruckButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToTruckButtonActionPerformed
        transferController.addSelectedToTruck();
        InputValidator.enabler2(truckTable, jButton1);
        InputValidator.enabler2(truckTable, clearTableButton);
    }//GEN-LAST:event_addToTruckButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        
        transferController.transferProducts();
           
    }//GEN-LAST:event_jButton1ActionPerformed

    private void transferFromComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transferFromComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_transferFromComboBoxActionPerformed

    private void removeItemButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeItemButtonActionPerformed
        transferController.removeSelectedRow();  
        InputValidator.enabler2(truckTable, jButton1);
        InputValidator.enabler2(truckTable, clearTableButton);
    }//GEN-LAST:event_removeItemButtonActionPerformed

    private void truckTableKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_truckTableKeyTyped

    }//GEN-LAST:event_truckTableKeyTyped

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        transferController.searchProduct();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void clearMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clearMouseClicked
        transferController.clearSearch();
        //InputValidator.enabler2(cartTable, jButton2);
        // InputValidator.enabler2(cartTable, clearTableButton);
    }//GEN-LAST:event_clearMouseClicked

    private void productFilterSupplierComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_productFilterSupplierComboBoxActionPerformed
        transferController.filterProducts();
    }//GEN-LAST:event_productFilterSupplierComboBoxActionPerformed

    private void filterCategoryComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterCategoryComboBoxActionPerformed
        transferController.filterProducts();
    }//GEN-LAST:event_filterCategoryComboBoxActionPerformed

    private void clearTableButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearTableButtonActionPerformed
        transferController.clearList();
        InputValidator.enabler2(truckTable, jButton1);
        InputValidator.enabler2(truckTable, clearTableButton);
    }//GEN-LAST:event_clearTableButtonActionPerformed

    private void transferToComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transferToComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_transferToComboBoxActionPerformed

    private void inputQuantityTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputQuantityTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_inputQuantityTextFieldActionPerformed

    private void inputQuantityTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputQuantityTextFieldKeyPressed
        if (evt.getKeyCode()== KeyEvent.VK_ENTER)
        {
            quantityInputButton.doClick();
            inputQuantityTextField.setText("");
        }
    }//GEN-LAST:event_inputQuantityTextFieldKeyPressed

    private void quantityCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quantityCancelButtonActionPerformed
        inputQuantityTextField.setText("");
        quantityInputDialog.setVisible(false);
    }//GEN-LAST:event_quantityCancelButtonActionPerformed

    private void quantityInputButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quantityInputButtonActionPerformed
        transferController.inputQuantityDialog();  
        inputQuantityTextField.setText("");
        InputValidator.enabler2(truckTable, jButton1);
        InputValidator.enabler2(truckTable, clearTableButton);
    }//GEN-LAST:event_quantityInputButtonActionPerformed

    private void editQuantityOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editQuantityOKActionPerformed
        transferController.editQuantityDialog();
        editQuantity.setText("");
    }//GEN-LAST:event_editQuantityOKActionPerformed

    private void editQuantityCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editQuantityCancelActionPerformed
        editQuantity.setText("");
        editQuantityDialog.dispose();
    }//GEN-LAST:event_editQuantityCancelActionPerformed

    private void editQuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editQuantityActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_editQuantityActionPerformed

    private void editQuantityKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_editQuantityKeyPressed
        if (evt.getKeyCode()== KeyEvent.VK_ENTER)
	{
            editQuantityOK.doClick();
            editQuantity.setText("");
	}
    }//GEN-LAST:event_editQuantityKeyPressed

    private void productTableSearchInputKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_productTableSearchInputKeyPressed
        if (evt.getKeyCode()== KeyEvent.VK_ENTER)
	{
            jButton3.doClick();
	}
    }//GEN-LAST:event_productTableSearchInputKeyPressed

    private void transferProductsTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_transferProductsTableKeyPressed
        if (evt.getKeyCode()==KeyEvent.VK_ENTER){
        transferController.addSelectedToTruck();
        InputValidator.enabler2(truckTable, jButton1);
        InputValidator.enabler2(truckTable, clearTableButton);
        }
    }//GEN-LAST:event_transferProductsTableKeyPressed

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
        editQuantityDialog.setVisible(true);
    }//GEN-LAST:event_editButtonActionPerformed

    private void quantityInputDialogWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_quantityInputDialogWindowClosed
        inputQuantityTextField.setText("");
    }//GEN-LAST:event_quantityInputDialogWindowClosed

    private void editQuantityDialogWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_editQuantityDialogWindowClosed
        editQuantity.setText("");
    }//GEN-LAST:event_editQuantityDialogWindowClosed

    private void editQuantityDialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_editQuantityDialogWindowClosing
        editQuantity.setText("");
    }//GEN-LAST:event_editQuantityDialogWindowClosing

    private void truckTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_truckTableKeyPressed
        if (evt.getKeyCode()==KeyEvent.VK_ENTER){
        editQuantityDialog.setVisible(true);
        }
    }//GEN-LAST:event_truckTableKeyPressed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        transferController.updateTransferHistoryTable();
        transferHistoryDialog.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void dateFromOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_dateFromOnSelectionChange
        transferController.updateTransferHistoryTable();
    }//GEN-LAST:event_dateFromOnSelectionChange

    private void dateToOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_dateToOnSelectionChange
        transferController.updateTransferHistoryTable();
    }//GEN-LAST:event_dateToOnSelectionChange

    private void dateFromOnCommit(datechooser.events.CommitEvent evt) {//GEN-FIRST:event_dateFromOnCommit
        transferController.updateTransferHistoryTable();
    }//GEN-LAST:event_dateFromOnCommit

    private void dateToOnCommit(datechooser.events.CommitEvent evt) {//GEN-FIRST:event_dateToOnCommit
        transferController.updateTransferHistoryTable();
    }//GEN-LAST:event_dateToOnCommit
    
    public static JTable getTransferProductsTable(){
        return transferProductsTable;
    }
    
    public static JComboBox<ComboItem> getTransferProductFilterCategoryComboBox(){
        return filterCategoryComboBox;
    }
    
    public static JComboBox<ComboItem> getTransferProductFilterSupplierComboBox(){
        return productFilterSupplierComboBox;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addToTruckButton;
    private javax.swing.JLabel clear;
    private javax.swing.JButton clearTableButton;
    private datechooser.beans.DateChooserCombo dateFrom;
    private datechooser.beans.DateChooserCombo dateTo;
    private javax.swing.JButton editButton;
    private javax.swing.JTextField editQuantity;
    private javax.swing.JButton editQuantityCancel;
    private javax.swing.JDialog editQuantityDialog;
    private javax.swing.JButton editQuantityOK;
    private static javax.swing.JComboBox<ComboItem> filterCategoryComboBox;
    private javax.swing.JTable historyTable;
    private javax.swing.JTextField inputQuantityTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    private static javax.swing.JComboBox<ComboItem> productFilterSupplierComboBox;
    private javax.swing.JTextField productTableSearchInput;
    private javax.swing.JButton quantityCancelButton;
    private javax.swing.JButton quantityInputButton;
    private javax.swing.JDialog quantityInputDialog;
    private javax.swing.JTextArea remarksTextArea;
    private javax.swing.JButton removeItemButton;
    private datechooser.beans.DateChooserCombo transferDate;
    private javax.swing.JDialog transferDialog;
    private javax.swing.JComboBox<ComboItem> transferFromComboBox;
    private javax.swing.JDialog transferHistoryDialog;
    private static javax.swing.JTable transferProductsTable;
    private javax.swing.JComboBox<ComboItem> transferToComboBox;
    private javax.swing.JTable truckTable;
    // End of variables declaration//GEN-END:variables
}
